import d0725_my_pie as mypie
import d0801_my_bar as mybar
import d0723_my_line as myline
import numpy as np
import json,time

dates = []
months = []
weeks = []
weekdays = []
close = []
dates1 = ["2017-03-31","2017-06-30","2017-09-30","2017-12-12"]
close1 = [7439,16943,28969,113732]
D = 20
Title = "请输入标题"
if __name__ == '__main__':
    with open(r"D:\python\exercise.json","r") as jsons:
        btc_dict = json.load(fp=jsons)
        for i in btc_dict:
            dates.append(i["date"][5:])
            months.append(int(i["month"]))
            weeks.append(eval(i["week"]))
            weekdays.append(i["weekday"])
            close.append(round(eval(i["close"]),-1))

    with open(r"D:\python\exercise.html","w",encoding="utf-8") as html:
        log_line = myline.My_Line(dates[::D],[np.log(i) for i in close[::D]],)
        log_line.rotation = 30
        html.write(f"<!DOCTYPE html>\n"
                   f"<html>\n"
                   f"\t<head>\n"
                   f"\t\t<title>{Title}</title>\n"
                   f"\t\t<meta charset=\"UTF-8\">\n"
                   f"\t</head>\n"
                   f"\t<body>\n"
                   f"\t\t<img src=r\"{log_line.show_lines()}\">\n")

        pie = mypie.My_Pie(dates1,close1,0,"Ends of seasons",
                           "Four seasons")
        html.write(f"\t\t<img src=r\"{pie.show_pie()}\">\n")

        bar = mybar.My_Bar(dates[::D],close[::D],title="The closes in 2017",ylabel="￥")
        html.write(f"\t\t<img src=r\"{bar.show_bar()}\">\n"
                   f"\t</body>\n"
                   f"</html>")
























